Skip to content

Refactor BmpTool into a dedicated API layer and expose manipulation f…#10

Merged
JacobBorden merged 2 commits intodevelopmentfrom
bmptool-api-refactor
May 31, 2025
Merged

Refactor BmpTool into a dedicated API layer and expose manipulation f…#10
JacobBorden merged 2 commits intodevelopmentfrom
bmptool-api-refactor

Conversation

@JacobBorden
Copy link
Owner

…unctions.

This commit significantly refactors the BmpTool to act as a true API layer over the core bitmap processing logic.

Key changes:

  • Modified BmpTool::load and BmpTool::save in src/format/bitmap.cpp to delegate more responsibility to the core library functions (::CreateMatrixFromBitmap, ::CreateBitmapFromMatrix), reducing redundant parsing and serialization logic.
  • Removed unused internal formatting helpers from src/format/.
  • Exposed 24 image manipulation functions (shrink, rotate, greyscale, color adjustments, blur, etc.) through the BmpTool API in include/bitmap.hpp. These functions now operate on BmpTool::Bitmap and return BmpTool::Result.
  • Implemented these API functions in src/format/bitmap.cpp, where they wrap calls to the core library, handling data conversion (RGBA for API, BGRA for internal matrix) and error propagation.
  • Updated main.cpp to exclusively use the BmpTool API for all bitmap operations, serving as an example of API usage.
  • Created tests/test_bmptool_api_manipulations.cpp with unit tests for the newly exposed BmpTool image manipulation functions.
  • Existing tests for core components (test_bitmap.cpp, test_bitmap_file.cpp) and relevant fuzz tests (fuzz_bitmap.cpp, fuzz_bmp_tool_save.cpp) were reviewed and confirmed/kept.

This refactoring provides a cleaner separation of concerns, with BmpTool now providing a consistent interface for all bitmap operations.

…unctions.

This commit significantly refactors the BmpTool to act as a true API
layer over the core bitmap processing logic.

Key changes:
- Modified `BmpTool::load` and `BmpTool::save` in `src/format/bitmap.cpp`
  to delegate more responsibility to the core library functions
  (::CreateMatrixFromBitmap, ::CreateBitmapFromMatrix), reducing
  redundant parsing and serialization logic.
- Removed unused internal formatting helpers from `src/format/`.
- Exposed 24 image manipulation functions (shrink, rotate, greyscale,
  color adjustments, blur, etc.) through the `BmpTool` API in
  `include/bitmap.hpp`. These functions now operate on
  `BmpTool::Bitmap` and return `BmpTool::Result`.
- Implemented these API functions in `src/format/bitmap.cpp`, where they
  wrap calls to the core library, handling data conversion (RGBA for API,
  BGRA for internal matrix) and error propagation.
- Updated `main.cpp` to exclusively use the `BmpTool` API for all
  bitmap operations, serving as an example of API usage.
- Created `tests/test_bmptool_api_manipulations.cpp` with unit tests
  for the newly exposed `BmpTool` image manipulation functions.
- Existing tests for core components (`test_bitmap.cpp`,
  `test_bitmap_file.cpp`) and relevant fuzz tests (`fuzz_bitmap.cpp`,
  `fuzz_bmp_tool_save.cpp`) were reviewed and confirmed/kept.

This refactoring provides a cleaner separation of concerns, with BmpTool
now providing a consistent interface for all bitmap operations.
…u'd like me to use, or are you asking me to do something with this information?
@JacobBorden JacobBorden merged commit b8eb1ed into development May 31, 2025
2 checks passed
@JacobBorden JacobBorden deleted the bmptool-api-refactor branch May 31, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant